#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main()
{ 
    Mat image=imread("/home/lwj/opencv_projeci/cz.png");
    Mat img,imgv;
    cvtColor(image,img,COLOR_BGR2GRAY);
    threshold(img,imgv,50,255,THRESH_BINARY);//二值化
    Mat imgg;
    distanceTransform(imgv,imgg,1,3,CV_32F);//距离变换
    imshow("juli",imgg);
    Mat kernel=getStructuringElement(MORPH_RECT, Size(3, 3));//定义内核
    dilate(imgv, imgg, kernel);//膨胀
    imshow("penzhang",imgg);
    erode(imgv, imgg, kernel);//腐蚀
    imshow("fushi",imgg);
    waitKey(0);
    return 0;
}